package com.fg.pro.model.trade.dto;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import lombok.Data;

import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;

@Data
public class GmOrderDto {

    @Data
    public class GmOrderRequest{
        public CommonListOrder common_list_order;
        public Page paging;
        @Data
        public class CommonListOrder{
            public Long order_receive_from_time;
            public Long order_receive_to_time;

            public CommonListOrder(Long order_receive_from_time, Long order_receive_to_time) {
                this.order_receive_from_time = order_receive_from_time;
                this.order_receive_to_time = order_receive_to_time;
            }
        }
        @Data
        public class Page{
            public Integer limit;
            public Integer offset;

            public Page(Integer limit) {
                this.limit = limit;
            }
        }

        public GmOrderRequest(Date date,Integer limit) {
            TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
            Calendar calendar = Calendar.getInstance();
            DateTime beginOfDay = DateUtil.beginOfDay(date);
            calendar.setTime(beginOfDay);
            long startTime = calendar.getTimeInMillis();

            DateTime endOfDay = DateUtil.endOfDay(date);
            calendar.setTime(endOfDay);
            long endTime = calendar.getTimeInMillis();

            CommonListOrder commonListOrder = new CommonListOrder(startTime, endTime);
            Page page = new Page(limit);
            this.common_list_order = commonListOrder;
            this.paging = page;
        }



        public GmOrderRequest(Date date,Integer limit,Integer offset) {
            TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
            Calendar calendar = Calendar.getInstance();
            DateTime beginOfDay = DateUtil.beginOfDay(date);
            calendar.setTime(beginOfDay);
            long startTime = calendar.getTimeInMillis();

            DateTime endOfDay = DateUtil.endOfDay(date);
            calendar.setTime(endOfDay);
            long endTime = calendar.getTimeInMillis();

            CommonListOrder commonListOrder = new CommonListOrder(startTime, endTime);
            Page page = new Page(limit);
            page.setOffset(offset);
            this.common_list_order = commonListOrder;
            this.paging = page;
        }
        public GmOrderRequest(Date start,Date end,Integer limit,Integer offset) {
            TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
            Calendar calendar = Calendar.getInstance();
            DateTime beginOfDay = DateUtil.beginOfDay(start);
            calendar.setTime(beginOfDay);
            long startTime = calendar.getTimeInMillis();

            DateTime endOfDay = DateUtil.endOfDay(end);
            calendar.setTime(endOfDay);
            long endTime = calendar.getTimeInMillis();

            CommonListOrder commonListOrder = new CommonListOrder(startTime, endTime);
            Page page = new Page(limit);
            page.setOffset(offset);
            this.common_list_order = commonListOrder;
            this.paging = page;
        }


        public GmOrderRequest(Date start,Date end,Integer offset) {
            TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
            Calendar calendar = Calendar.getInstance();
            DateTime beginOfDay = DateUtil.beginOfDay(start);
            calendar.setTime(beginOfDay);
            long startTime = calendar.getTimeInMillis();

            DateTime endOfDay = DateUtil.endOfDay(end);
            calendar.setTime(endOfDay);
            long endTime = calendar.getTimeInMillis();

            CommonListOrder commonListOrder = new CommonListOrder(startTime, endTime);
            Page page = new Page(999);
            page.setOffset(offset);
            this.common_list_order = commonListOrder;
            this.paging = page;
        }
    }


    @Data
    public class GmOrderReponse{
        public List<GmOrderData> orders;
        public paging paging;

        @Data
        public class paging{
            public boolean has_more;
            public Integer count;
        }

        @Data
        public class GmOrderData{
            public Long order_id;
            public Integer status;
            public Long revision;
            public Long create_time;
            public Long update_time;
            public Long use_time;
            public Long group_id;
            public Long station_id;
            public Long creator_id;
            public Long bill_customer_id;
            public Long driver_id;
            public Long receive_customer_id;
            public Long service_period_id;
            public Long quotation_id;
            public Integer customer_type;
//            public Address addresses;
//            public service_period service_period;
            public Long updater_id;
            public Double order_price;
            public Double aftersale_price;
            public Double outstock_price;
            public Double sale_price;
            public Double sale_price_no_tax;
            public Double sale_price_no_aftersale;
            public Double sale_price_no_tax_no_aftersale;
            public Double detail_sum_sale_price;
            public Double detail_sum_sale_price_no_tax;
            public Double detail_sum_tax_price;
            public Double total_add_order_price;
            public Double fake_order_price;
            public Double fake_outstock_price;
            public Integer is_real_order;
            public Double fake_print_price;
            public Double add_order_price1;
            public Double add_order_price2;
            public Double add_order_price3;
            public Double add_order_price4;
            public Double paid_amount;
            public Long receive_time;
            public Long outstock_time;
            public Long order_time;
            public String time_zone;
            public String serial_no;
            public Integer state;
            public Integer pay_state;
            public Integer order_type;
            public Integer creator_id_type;
            public String remark;
            public Integer app_type;
            public SortingInfo sorting_info;
            public Integer order_op;
            public Integer updater_id_type;
            public Long customer_id_l1;
            public Long customer_id_l2;
            public Integer supplier_cooperate_model_type;
            public Integer detail_length;
            public Integer raw_detail_length;
            public Integer detail_category_length;
            public Boolean is_all_price_record;
            public Integer outstock_state;
            public Integer lock_state;
            public Integer total_add_order_value_quantity;
            public Double extra_order_price;
            public String receive_customer_name;
            public String cost;
            public OrderDetails order_details;

            @Data
            public class OrderDetails{
                public List<OrderDetailsData> order_details;

                @Data
                public class OrderDetailsData{
                    public Long order_detail_id;
                    public Long revision;
                    public Long create_time;
                    public Long update_time;
                    public Integer type;
                    public Long group_id;
                    public Long order_id;
                    public Long sku_id;
                    public Long station_id;
                    public Long detail_random_id;
                    public Integer add_order_price1;
                    public Integer add_order_price2;
                    public Integer add_order_price3;
                    public Integer add_order_price4;
                    public Double total_add_order_price;
                    public Double fake_order_price;
                    public Double fake_outstock_price;
                    public Integer is_print;
                    public Integer fake_type;
                    public Double order_price;
                    public Double outstock_price;
                    public Double sale_price;
                    public Double sale_price_no_tax;
                    public Double tax_price;
                    public Double outstock_cost_price;
                    public Double outstock_per_cost_price;
                    public Integer sorting_status;
                    public Integer sort_num;
                    public Integer supplier_cooperate_model_type;
                    public Long unit_id;
                    public Long sku_revision;
                    public Long fee_unit_id;
                    public Long measure_unit_id;
                    public String sku_name;
                    public String sku_customize_code;
                    public Long receive_customer_id;
                    public String cost;
                    public Double fee_price;
                    public Integer is_need_take_out;
                    public String receive_customer_name;
                    public Long supplier_id;
                    public Long category1_id;
                    public Long category2_id;
                    public String category1_name;
                    public String category2_name;
                    public Integer outstock_state;
                    public String serial_no;
                    public Double order_unit_quantity;
                    public Double outstock_unit_quantity;
                    public Long outstock_unit_id;
                    public Double outstock_base_unit_quantity;
                    public Long outstock_base_unit_id;
                    public Integer total_add_order_value_quantity;
                    public Integer accept_value_quantity;
                    public Double original_price;
                    public Long original_unit_id;
                    public Integer original_rate;
                    public Double tax;
                }
            }

            @Data
            public class SortingInfo{
                public Integer total_count;
                public Integer unweight_count;
                public Integer weight_count;
                public Integer out_stock_count;
            }
        }
    }

    public static void main(String[] args) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(DateUtil.beginOfDay(new Date()));
        long startTime = calendar.getTimeInMillis();
        System.out.println(startTime);

        calendar.setTime(DateUtil.endOfDay(new Date()));
        long end = calendar.getTimeInMillis();
        System.out.println(end);
    }

}















